@extends('layouts.master')
@section('content')
    <div class="row">
        <div class="col-lg-12">
            <div class="ibox">
                <div class="ibox-content">
                    <form class="layui-form" action="">
                        <div class="layui-inline">
                            <div class="layui-input-inline">
                                <input type="text" name="query[keywords]" lay-verify="" placeholder="商户名称/联系人/手机号"
                                       style="width: 200px;" value="{{$query['keywords']}}" autocomplete="off"
                                       class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline" style="padding-bottom: 5px">
                            <div class="layui-input-inline">
                                <input type="hidden" name="page_num" value="{{$currentPageNum}}">
                                <button name="submit" class="btn btn-success" type="submit">搜索</button>
                            </div>
                        </div>
                    </form>
                    @section('toolbar')
                        <span class="left">
                            <a class="btn btn-primary" href="{{route('shop.create')}}"><i
                                        class="fa fa-plus"></i>&nbsp;添加商户</a>
                        </span>
                    @endsection
                    @include('common.toolbar', ['pager' => $pager])
                    <table class="layui-table">
                        <thead>
                        <tr>
                            <th>ID</th>
                            <th>商户</th>
                            <th>主营项目</th>
                            <th>联系人</th>
                            <th>入驻时间</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        @foreach($pager as $item)
                            <tr>
                                <td>{{$item->id}}</td>

                                <td>
                                    <img src="{{$item->avatar}}"
                                           class="rounded-circle img-sm img_pop_show"/><br/>
                                    {{$item->name}}</td>
                                <td>{{$item->salecate}}</td>
                                <td>
                                    {{$item->realname}}<br/>
                                    {{$item->phone}}
                                </td>
                                <td>
                                    @if($item->join_time)
                                        @php echo date('Y-m-d H:i:s',$item->join_time);@endphp
                                    @else
                                        -
                                    @endif
                                </td>
                                <td>
                                    <a href="{{route('shop.edit',['id'=>$item->id])}}"
                                       class="btn btn-info " type="button"><i class="fa fa-paste"></i> 编辑</a>
                                    <button class="btn btn-danger ajax-confirm delete" type="button"
                                            data-title="删除商品后不可恢复，确定吗？"
                                            data-url="{{route('shop.destroy',[$item->id])}}">
                                        <i class="fa fa-trash-o"></i> 删除
                                    </button>
                                </td>
                            </tr>
                        @endforeach
                        </tbody>
                    </table>
                    @include('common.pagination', ['pager' => $pager])
                </div>
            </div>
        </div>
    </div>
@endsection

@section('script')
    <script>
        layui.use(['laydate', 'element', 'form'], function () {
            var laydate = layui.laydate, element = layui.element;
            var form = layui.form;
            var layer = layui.layer;

            //日期时间选择器
            laydate.render({
                elem: '.start_time'
                , type: 'datetime'
            });
            laydate.render({
                elem: '.end_time'
                , type: 'datetime'
            });
        });

    </script>
@endsection